#配置文件
import pytest
import yaml
from appium import webdriver

from page.app import App

caps = {}
caps["platformName"] = "Android"
caps['deviceName'] = 'emulator-5554'
caps['appPackage'] = 'com.tencent.wework'
caps['appActivity'] = '.launch.LaunchSplashActivity'
#防止清空缓存-比如登录信息
caps['noReset'] = 'true'

parameters_path = "../parameters/"

@pytest.fixture(scope="class")
def android_load():
    # 最重要的一部，与server建立连接
    driver = webdriver.Remote('http://localhost:4723/wd/hub', caps)
    # 隐式等待5秒
    app = App(driver)
    driver.implicitly_wait(5)
    # 打开应用，进入到首页
    main = app.goto_to_main()
    yield main
    app.stop()

#读取测试数据yaml数据文件
def read_yaml(filename):
    with open(f"../parameters/{filename}") as f:
        return yaml.safe_load(f)